package com.tz.crm.dao.impl;

import com.tz.crm.dao.VisitTypeDao;
import com.tz.crm.entity.VisitType;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 使用 @Repository 将 DAO 类声明为 Bean
 */
@Repository
@Transactional
public class VisitTypeDaoImpl extends BaseDaoImpl<VisitType, String> implements VisitTypeDao {

    @SuppressWarnings("unchecked")
    @Override
    public List<VisitType> getAllOrderBySeq() {
        String hql = "from VisitType vt order by vt.req asc";
        return getSession().createQuery(hql)
                .list();
    }

    @Override
    public VisitType findByValue(String value) {
        String hql = "from VisitType vt where vt.value =:v";
        return (VisitType) getSession().createQuery(hql)
                .setParameter("v", value)
                .uniqueResult();
    }

}
